/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * VerEventoGerente.java
 *
 * Created on 26/06/2012, 16:52:55
 */
package View;

import Controller.Controller;
import Model.Evento;
import Model.Ingresso;
import javax.swing.JOptionPane;

/**
 *
 * @author lcc
 */
public class VerEventoGerente extends javax.swing.JFrame {

    private Controller controller;
    private Evento evento;

    /** Creates new form VerEventoGerente */
    public VerEventoGerente() {
        initComponents();
    }

    VerEventoGerente(Evento evento) {
        initComponents();
        this.evento = evento;
        controller = Controller.getInstance();
        titulo.setText(evento.getTituloShow());
        if (evento.getArtistas().isEmpty()) {
            labelArtistas.setVisible(false);
            artista1Nome.setVisible(false);
            artista1Gene.setVisible(false);
            artista2Nome.setVisible(false);
            artista2Gene.setVisible(false);
            artista3Nome.setVisible(false);
            artista3Gene.setVisible(false);
        } else if (evento.getArtistas().size() == 1) {
            artista1Nome.setText(evento.getArtistas().get(0).getNome());
            artista1Gene.setText(evento.getArtistas().get(0).getGenero());
            artista2Nome.setVisible(false);
            artista2Gene.setVisible(false);
            artista3Nome.setVisible(false);
            artista3Gene.setVisible(false);
        } else if (evento.getArtistas().size() == 2) {
            artista1Nome.setText(evento.getArtistas().get(0).getNome());
            artista1Gene.setText(evento.getArtistas().get(0).getGenero());
            artista2Nome.setText(evento.getArtistas().get(1).getNome());
            artista2Gene.setText(evento.getArtistas().get(1).getGenero());
            artista3Nome.setVisible(false);
            artista3Gene.setVisible(false);
        } else {
            artista1Nome.setText(evento.getArtistas().get(0).getNome());
            artista1Gene.setText(evento.getArtistas().get(0).getGenero());
            artista2Nome.setText(evento.getArtistas().get(1).getNome());
            artista2Gene.setText(evento.getArtistas().get(1).getGenero());
            artista3Nome.setText(evento.getArtistas().get(2).getNome());
            artista3Gene.setText(evento.getArtistas().get(2).getGenero());
        }
        cancelado.setVisible(evento.getCancelado());
        qtdTotalIngressos.setText(evento.getTextoIngressos());
        infoProdutor.setText(evento.getInfoProdutor());
        valorAluguel.setText(Float.toString(evento.getValorDoAluguel()));
        porcentagem.setText(Float.toString(evento.getPorcentagemVendaIngressos())+"%");
        inicio.setText(evento.getInicioString());
        fim.setText(evento.getFimString());
        tipoAcomodacao.setText(evento.getTipoAcomodacao());
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        titulo = new javax.swing.JLabel();
        labelArtistas = new javax.swing.JLabel();
        artista1Nome = new javax.swing.JLabel();
        artista1Gene = new javax.swing.JLabel();
        artista2Nome = new javax.swing.JLabel();
        artista2Gene = new javax.swing.JLabel();
        artista3Nome = new javax.swing.JLabel();
        artista3Gene = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        qtdTotalIngressos = new javax.swing.JLabel();
        botaoVoltar = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        infoProdutor = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        valorAluguel = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        porcentagem = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        inicio = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        fim = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        tipoAcomodacao = new javax.swing.JLabel();
        cancelarEventoButton = new javax.swing.JButton();
        venderIngressoButton = new javax.swing.JButton();
        cancelado = new javax.swing.JLabel();
        calcularArrecadacaoButton = new javax.swing.JButton();
        cancelarIngressoButton = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        titulo.setFont(new java.awt.Font("Tahoma", 1, 24));
        titulo.setText("Detalhes do Evento");

        labelArtistas.setText("Artistas Participantes:");

        artista1Nome.setText("Artista1Nome");

        artista1Gene.setText("Artista1Genero");

        artista2Nome.setText("Artista2Nome");

        artista2Gene.setText("Artista2Genero");

        artista3Nome.setText("Artista3Nome");

        artista3Gene.setText("Artista3Genero");

        jLabel8.setText("Ingressos:");

        qtdTotalIngressos.setText("QtdIngressos");

        botaoVoltar.setText("Voltar");
        botaoVoltar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoVoltarActionPerformed(evt);
            }
        });

        jLabel10.setText("Produtor:");

        infoProdutor.setText("Nome - Produtora");

        jLabel12.setText("Valor do Aluguel:");

        valorAluguel.setText("valorAluguel");

        jLabel14.setText("Porcentagem de Lucro:");

        porcentagem.setText("porcentagem");

        jLabel16.setText("Início:");

        inicio.setText("inicio");

        jLabel18.setText("Fim:");

        fim.setText("fim");

        jLabel20.setText("Tipo de Acomodação:");

        tipoAcomodacao.setText("tipoAcomodacao");

        cancelarEventoButton.setText("Cancelar Evento");
        cancelarEventoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelarEventoButtonActionPerformed(evt);
            }
        });

        venderIngressoButton.setText("Vender Ingresso");
        venderIngressoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                venderIngressoButtonActionPerformed(evt);
            }
        });

        cancelado.setFont(new java.awt.Font("Tahoma", 1, 11));
        cancelado.setForeground(new java.awt.Color(255, 0, 0));
        cancelado.setText("Este evento está CANCELADO!");

        calcularArrecadacaoButton.setText("Calcular Arrecadação");
        calcularArrecadacaoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                calcularArrecadacaoButtonActionPerformed(evt);
            }
        });

        cancelarIngressoButton.setText("Cancelar Ingresso");
        cancelarIngressoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelarIngressoButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(86, 86, 86)
                        .addComponent(titulo))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(57, 57, 57)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(artista1Nome)
                            .addComponent(labelArtistas)
                            .addComponent(artista2Nome)
                            .addComponent(artista3Nome)
                            .addComponent(jLabel8)
                            .addComponent(jLabel10)
                            .addComponent(jLabel12)
                            .addComponent(jLabel14))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(porcentagem)
                                    .addComponent(valorAluguel)
                                    .addComponent(infoProdutor)
                                    .addComponent(qtdTotalIngressos)
                                    .addComponent(artista3Gene)
                                    .addComponent(artista2Gene)
                                    .addComponent(artista1Gene))
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(78, 78, 78)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel16)
                                            .addComponent(jLabel18)
                                            .addComponent(jLabel20))
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(tipoAcomodacao)
                                            .addComponent(fim)
                                            .addComponent(inicio)))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(114, 114, 114)
                                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(venderIngressoButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(cancelarEventoButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(calcularArrecadacaoButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(cancelarIngressoButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 135, Short.MAX_VALUE)))))
                            .addComponent(cancelado)))
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(botaoVoltar)))
                .addContainerGap(334, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(titulo)
                .addGap(11, 11, 11)
                .addComponent(cancelado)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(labelArtistas)
                    .addComponent(jLabel16)
                    .addComponent(inicio))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(artista1Nome)
                    .addComponent(artista1Gene)
                    .addComponent(jLabel18)
                    .addComponent(fim))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(artista2Nome)
                    .addComponent(artista2Gene)
                    .addComponent(jLabel20)
                    .addComponent(tipoAcomodacao))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(artista3Nome)
                            .addComponent(artista3Gene))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8)
                            .addComponent(qtdTotalIngressos))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel10)
                            .addComponent(infoProdutor))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel12)
                            .addComponent(valorAluguel))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel14)
                            .addComponent(porcentagem))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 47, Short.MAX_VALUE)
                        .addComponent(botaoVoltar))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(50, 50, 50)
                        .addComponent(cancelarEventoButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(venderIngressoButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(calcularArrecadacaoButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cancelarIngressoButton)))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botaoVoltarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoVoltarActionPerformed
        TelaGerente tg = new TelaGerente();
        tg.setVisible(true);
        this.setVisible(false);
    }//GEN-LAST:event_botaoVoltarActionPerformed

    private void cancelarEventoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarEventoButtonActionPerformed
// TODO add your handling code here:
       controller.cancelarEvento(evento);
    }//GEN-LAST:event_cancelarEventoButtonActionPerformed

    private void venderIngressoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_venderIngressoButtonActionPerformed
// TODO add your handling code here:
        if (evento.getTipoAcomodacao().equals("Em Pé")) {
            LugaresEmPe tela = new LugaresEmPe(evento);
            tela.setVisible(true);
        } else {
            LugaresSentado tela = new LugaresSentado(evento);
            tela.setVisible(true);
        }
        this.setVisible(false);
    }//GEN-LAST:event_venderIngressoButtonActionPerformed


    private void calcularArrecadacaoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_calcularArrecadacaoButtonActionPerformed
        float arrecadacao = evento.getValorDoAluguel();
        for (Ingresso i : evento.getIngressos()) {
            if (i.isVendido()) {
                arrecadacao += evento.getPrecoIngresso() * evento.getPorcentagemVendaIngressos() / 100.f;
            }
        }
        JOptionPane.showMessageDialog(artista1Gene, "Valor Arrecadado : "+arrecadacao);
    }//GEN-LAST:event_calcularArrecadacaoButtonActionPerformed


    private void cancelarIngressoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarIngressoButtonActionPerformed
// TODO add your handling code here:
        if (evento.getTipoAcomodacao().equals("Em Pé")) {
            CancelaIngressoEmPe tela = new CancelaIngressoEmPe(evento);
            tela.setVisible(true);
        } else {
            CancelaIngressoSentado tela = new CancelaIngressoSentado(evento);
            tela.setVisible(true);
        }
        this.setVisible(false);
    }//GEN-LAST:event_cancelarIngressoButtonActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new VerEventoGerente().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel artista1Gene;
    private javax.swing.JLabel artista1Nome;
    private javax.swing.JLabel artista2Gene;
    private javax.swing.JLabel artista2Nome;
    private javax.swing.JLabel artista3Gene;
    private javax.swing.JLabel artista3Nome;
    private javax.swing.JButton botaoVoltar;
    private javax.swing.JButton calcularArrecadacaoButton;
    private javax.swing.JLabel cancelado;
    private javax.swing.JButton cancelarEventoButton;
    private javax.swing.JButton cancelarIngressoButton;
    private javax.swing.JLabel fim;
    private javax.swing.JLabel infoProdutor;
    private javax.swing.JLabel inicio;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel labelArtistas;
    private javax.swing.JLabel porcentagem;
    private javax.swing.JLabel qtdTotalIngressos;
    private javax.swing.JLabel tipoAcomodacao;
    private javax.swing.JLabel titulo;
    private javax.swing.JLabel valorAluguel;
    private javax.swing.JButton venderIngressoButton;
    // End of variables declaration//GEN-END:variables
}
